// Package main provides ...
package main

import "fmt"

func main() {
	data := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	s1 := data[8:]
	s2 := data[:5]

	copy(s2, s1)

	fmt.Printf("s2=%v\n", s2) //s2=[9 2 3 4 5]
	deleteNode()
}

/**
练习: 删除slice 中间的某个元素并保存原有的元素顺序
**/

func deleteNode() {
	data := []int{1, 2, 3, 4, 5} //删除元素 3

	copy(data[2:], data[2+1:])

	data = data[:len(data)-1]

	fmt.Printf("data=%v\n", data)
}
